package com.bishe.util;
 
import cn.hutool.core.bean.BeanUtil;
 
import java.util.List;
import java.util.stream.Collectors;
 
public final class BeansUtil {
    private BeansUtil() {
    }
 
    public static <T1, T2> List<T2> listCopy(List<T1> sourceList, Class<T2> clazz) {
        return (List) sourceList.stream().map((source)->{
            Object target;
            try {
                target = clazz.getDeclaredConstructor().newInstance();
            } catch (Exception e) {
                throw new RuntimeException();
            }
            BeanUtil.copyProperties(source, target);
            return target;
        }).collect(Collectors.toList());
    }
}
 